import java.util.concurrent.CountDownLatch;

public class testDemo {

    public static void main(String[] args) throws Exception {
        CountDownLatch latch = new CountDownLatch(10);
        Runnable r = new Runnable() {
            @Override
            public void run() {
                try{
                    Thread.sleep(500);
                    System.out.println("完成一个任务");
                    latch.countDown();

                }catch(Exception e){
                    e.printStackTrace();
                }
            }
        };

        for (int i = 0; i < 10; i++) {
            new Thread(r).start();
        }
        latch.await();
        System.out.println("比赛结束");
    }





}
